package ar.org.fiel.tarifasocial.om.base;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;

import ar.org.fiel.tarifasocial.om.model.*;

import ar.org.fiel.tarifasocial.om.peer.*;

        

/**
 * This class was autogenerated by Torque on:
 *
 * [Mon Jun 18 20:18:58 ART 2007]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to Parameter
 */
public abstract class BaseParameter extends BaseObject
{
    /** The Peer class */
    private static final ParameterPeer peer =
        new ParameterPeer();

        
    /** The value for the id field */
    private Integer id;
      
    /** The value for the code field */
    private String code;
      
    /** The value for the description field */
    private String description;
      
    /** The value for the value field */
    private String value;
  
            
    /**
     * Get the Id
     *
     * @return Integer
     */
    public Integer getId()
    {
        return id;
    }

                        
    /**
     * Set the value of Id
     *
     * @param v new value
     */
    public void setId(Integer v) 
    {
    
                  if (!ObjectUtils.equals(this.id, v))
              {
            this.id = v;
            setModified(true);
        }
    
          
              }
          
    /**
     * Get the Code
     *
     * @return String
     */
    public String getCode()
    {
        return code;
    }

                        
    /**
     * Set the value of Code
     *
     * @param v new value
     */
    public void setCode(String v) 
    {
    
                  if (!ObjectUtils.equals(this.code, v))
              {
            this.code = v;
            setModified(true);
        }
    
          
              }
          
    /**
     * Get the Description
     *
     * @return String
     */
    public String getDescription()
    {
        return description;
    }

                        
    /**
     * Set the value of Description
     *
     * @param v new value
     */
    public void setDescription(String v) 
    {
    
                  if (!ObjectUtils.equals(this.description, v))
              {
            this.description = v;
            setModified(true);
        }
    
          
              }
          
    /**
     * Get the Value
     *
     * @return String
     */
    public String getValue()
    {
        return value;
    }

                        
    /**
     * Set the value of Value
     *
     * @param v new value
     */
    public void setValue(String v) 
    {
    
                  if (!ObjectUtils.equals(this.value, v))
              {
            this.value = v;
            setModified(true);
        }
    
          
              }
  
         
                
     
    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
          save(ParameterPeer.getMapBuilder()
                .getDatabaseMap().getName());
      }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
       * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
       *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
          try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }
      }

      /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
      /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
          if (!alreadyInSave)
        {
            alreadyInSave = true;


  
            // If this object has been modified, then save it to the database.
            if (isModified())
            {
                if (isNew())
                {
                    ParameterPeer.doInsert((Parameter) this, con);
                    setNew(false);
                }
                else
                {
                    ParameterPeer.doUpdate((Parameter) this, con);
                }
                }

                      alreadyInSave = false;
        }
      }

                  
      /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param key id ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        
    {
            setId(new Integer(((NumberKey) key).intValue()));
        }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) 
    {
            setId(new Integer(key));
        }

  
    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
          return SimpleKey.keyFor(getId());
      }
 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
       * It then fills all the association collections and sets the
     * related objects to isNew=true.
       */
      public Parameter copy() throws TorqueException
    {
        return copyInto(new Parameter());
    }
  
    protected Parameter copyInto(Parameter copyObj) throws TorqueException
    {
          copyObj.setId(id);
          copyObj.setCode(code);
          copyObj.setDescription(description);
          copyObj.setValue(value);
  
                    copyObj.setId((Integer)null);
                              
                return copyObj;
    }

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public ParameterPeer getPeer()
    {
        return peer;
    }


    public String toString()
    {
        StringBuffer str = new StringBuffer();
        str.append("Parameter:\n");
        str.append("Id = ")
               .append(getId())
             .append("\n");
        str.append("Code = ")
               .append(getCode())
             .append("\n");
        str.append("Description = ")
               .append(getDescription())
             .append("\n");
        str.append("Value = ")
               .append(getValue())
             .append("\n");
        return(str.toString());
    }
}
